﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Blog.Models.CommentServices
{
    public class CommentRepository:ICommentRepository
    {
        private DataDataContext db = new DataDataContext();
        public IQueryable<Comment> FindAlldata()
        {
            return db.Comments;
        }

        public Comment GetByIdMax()
        {
            throw new System.NotImplementedException();
        }

        public Comment Getdata(int id)
        {
            return (from c in db.Comments
                    where c.CommentId == id
                    select c).FirstOrDefault();
        }

        public void Add(Comment data)
        {
            db.Comments.InsertOnSubmit(data);
        }

        public void Delete(Comment data)
        {
            db.Comments.DeleteOnSubmit(data);
        }

        public void Save()
        {
            db.SubmitChanges();
        }
    }
}
